package regpang.listviewtest.SwipeRecyclerView;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.util.List;

import regpang.listviewtest.R;

/**
 * 侧滑可删除
 * Created by AndroidDeveloper on 2016/11/7 0007.
 */

public class SwieRecyclerAdapter extends RecyclerView.Adapter<SwieRecyclerAdapter.VH> {
    private Context context;
    private List<String> list;

    public SwieRecyclerAdapter(Context context, List<String> list) {
        this.context = context;
        this.list = list;
    }

    //返回视图，使用ViewHolder返回
    @Override
    public VH onCreateViewHolder(ViewGroup parent, int viewType) {
        //返回视图
        View inflate = LayoutInflater.from(context).inflate(R.layout.item_linear, parent, false);
        return new VH(inflate);
    }

    @Override
    public void onBindViewHolder(VH holder, final int position) {
        holder.tv_title.setText("侧滑删除" + list.get(position));
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public static class VH extends RecyclerView.ViewHolder {
        TextView tv_title;
        ImageView img;
        LinearLayout ll_item, ll_hidden;

        public VH(View itemView) {
            super(itemView);
            tv_title = (TextView) itemView.findViewById(R.id.tv_title);
            img = (ImageView) itemView.findViewById(R.id.img);

            ll_item = (LinearLayout) itemView.findViewById(R.id.ll_item);
            ll_hidden = (LinearLayout) itemView.findViewById(R.id.ll_hidden);
        }
    }
}
